#ifndef __CONFIG_H_2010_07_22_21_27_35
#define __CONFIG_H_2010_07_22_21_27_35

class config
{
private:
	map<string, int>	m_int_items;
	map<string, bool>	m_bool_items;
	map<string, string>	m_string_item;
	string				m_file_path;

public:
	bool load(const string& file_path)
	{
		m_file_path = file_path;

		return reload();
	}

	bool save(const string& file_path)
	{
		m_file_path = file_path;
		return true;
	}

	bool reload()
	{
		FILE* fp = fopen(m_file_path.c_str(), "r");
		if (!fp)
			return false;

		m_int_items.clear();
		m_bool_items.clear();
		m_string_item.clear();

		int int_num;
		char buffer[2048];
		int readed_len = fread(buffer, sizeof(int), 1);
		if (readed_len <= 0)
		{
			fclose(fp);
			return false;
		}

		return true;
	}

	int get_int(const string& key, int default_value)
	{
		if (m_int_items.find(key) != m_int_items.end())
			return m_int_items[key];
		return default_value;
	}

	bool get_bool(const string& key, bool default_value)
	{
		if (m_bool_items.find(key) != m_bool_items.end())
			return m_bool_items[key];
		return default_value;
	}

	string get_string(const string& key, const string& default_value)
	{
		if (m_string_item.find(key) != m_string_item.end())
			return m_string_item[key];
		return default_value;
	}
/*
	bool get_int_raw(const string& key, int& value)
	{
		if (m_int_items.find(key) == m_int_items.end())
			return false;
		
		value = m_int_items[key];

		return true;
	}

	bool get_bool_raw(const string& key, bool& value)
	{
		if (m_bool_items.find(key) == m_bool_items.end())
			return false;
		
		value = m_bool_items[key];

		return true;
	}

	bool get_string_raw(const string& key, string& value)
	{
		if (m_string_item.find(key) == m_string_item.end())
			return false;
		
		value = m_string_item[key];

		return true;
	}
*/
	void set_int(const string& key, int value)
	{
		m_int_items[key] = value;
	}

	void set_bool(const string& key, bool value)
	{
		m_bool_items[key] = value;
	}

	void set_string(const string& key, string& value)
	{
		m_string_item[key] = value;

		return true;
	}
};

class XmlConfig : public config
{
	;
};

class BinaryConfig : public config
{
	;
};

template<typename Document>
class Config
{
public:
	Config() {}
private:
	Document m_doc;
};

#endif